home *** CD-ROM | disk | FTP | other *** search
- techinfo.doc
-
- Here's some technical information for those of you who want to know how the
- resource tracking works.
-
- The first thing "rt" does is to allocate space for a semaphore and a
- minimal list header. The semaphore is initialized and added to the public
- system semaphore list where other programs can find and use it to access
- the list.
- Then the config file is parsed and a patch function called for every valid
- library entry. This function does the following:
- - allocate a minimal node, a special ResourceList structure and space for
- two functions to be patched into the allocation/deallocation functions
- respectively.
- - initialize the ResourceList
- - initialize a memory pool for use by the patch functions
- - copy the two patch routines in place
- - modify the patch code to make it use the correct registers for
- (de-)allocation of resources. Yea, I know self-modifying code is a no-no
- but for performance reasons there was no better way to do it. At least I
- finally
- - clear the CPU caches!
-
- The LVOs of the patched OS functions, the library name and some other info
- from the config file are stored in the ResourceList which is then added to
- the main list by its node part after the actual patching took place.
-
- Every time a resource allocation is requested, the patch allocates a node
- structure with space for a resource pointer and a task pointer using its
- private memory pool. This node is then added to the ResourceList. On
- resource deallocation the ResourceList is searched (newest entries first to
- speed things up) for the given resource. If the resource was found, the
- node is removed from the list and its memory given back to the pool.
-
- To give resources allocated by a crashed task back to the system, the
- following steps are needed:
- - find the crashed task's address
- - find and gain access to the public sempahore called "ResourceTracker"
- - get the MinList structure directly attached to the sempahore
- - while there are nodes left in this MinList do
- - get the ResourceList structure directly attached to any node
- - while there are nodes left in this ResourceList do
- - compare every node's task field with the crashed task's address
- - if they are equal
- - get the LibName and FreeOffset fields from the current ResourceList
- - open the library and pass the current node's resource field to the
- deallocation function
- - proceed to next ResourceNode
- - proceed to next node
- - release the main list semaphore
-